<!DOCTYPE html>
<html lang="en">
<head>
    <title>eStore管理系统</title>
    <meta charset="UTF-8"/>
    <meta name="viewport" content="width=device-width, initial-scale=1.0"/>
    <link rel="stylesheet" href="${request.contextPath}/css/bootstrap.min.css"/>
    <link rel="stylesheet" href="${request.contextPath}/css/bootstrap-responsive.min.css"/>
    <link rel="stylesheet" href="${request.contextPath}/css/matrix-login.css"/>
    <link href="${request.contextPath}/css/font-awesome.css" rel="stylesheet"/>
</head>
<body>
<div id="loginbox">
    <form id="loginform" class="form-vertical" action="#">
        <div class="control-group normal_text"><h3>eStore 管理系统</h3></div>
        <div class="control-group">
            <div class="controls">
                <div class="main_input_box">
                    <span class="add-on bg_lg"><i class="icon-user"></i></span><input type="text" name="account_name"
                                                                                      placeholder="输入用户名"/>
                </div>
            </div>
        </div>
        <div class="control-group">
            <div class="controls">
                <div class="main_input_box">
                    <span class="add-on bg_ly"><i class="icon-lock"></i></span><input type="password" name="password"
                                                                                      placeholder="输入密码"/>
                </div>
            </div>

        </div>
        <div class="text-center label label-important" id="message" style="width:100%; display: none;"></div>
        <div class="form-actions">
            <!--<span class="pull-left"><a href="#" class="flip-link btn btn-info" id="to-recover">Lost password?</a></span>-->
            <!--<span class="pull-right"><a type="submit" href="demo.html" class="btn btn-success" id="login"/> Login</a></span>-->
            <button type="submit" id="login" class="btn btn-success btn-large btn-block">登录</button>

        </div>

    </form>
</div>

<script src="${request.contextPath}/js/jquery-1.12.2.min.js"></script>
<script src="${request.contextPath}/js/matrix.login.js"></script>
<script type="text/javascript">
    $(function () {
        $("#login").click(function () {
            $("#message").hide();
            var accountName = $(":input[name='account_name']").val();
            var password = $(":input[name='password']").val();
            if (accountName.length == 0) {
                show_message("账号不能为空！");
            }
            else if (password.length == 0) {
                show_message("密码不能为空！");
            }
            else {
                $.post("${request.contextPath}/account/login", {
                    account_name: accountName,
                    password: password
                }, function (data) {
                    if (data.status == "error") {
                        show_message(data.result);
                    }
                    else {
                        window.location.href = data.result;
                    }
                });
            }
            return false;
        });

        function show_message(message){
            $("#message").html(message).fadeIn(300);
        }
    });
</script>
</body>
</html>
